package com.xoa.service.flowRunFeedback;

import com.xoa.dao.flowRunFeedback.FlowRunFeedbackMapper;
import com.xoa.model.flowRunFeedback.FlowRunFeedback;
import com.xoa.util.AjaxJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FlowRunFeedbackService {

    @Autowired
    FlowRunFeedbackMapper flowRunFeedbackMapper;

    public AjaxJson findFinalfeedback(Integer runId, String feedFlag){
        AjaxJson ajaxJson = new AjaxJson();
        try{
            List<FlowRunFeedback> list = flowRunFeedbackMapper.findFinalfeedbackByDataId(runId, feedFlag);
            for (FlowRunFeedback flowRunFeedback : list){
                if (flowRunFeedback.getEditTime()!="2000-01-01 00:00:00"){
                    flowRunFeedback.setEditTime(flowRunFeedback.getEditTime().substring(0,flowRunFeedback.getEditTime().length()-2));
                }

            }
            ajaxJson.setObj(list);
            ajaxJson.setMsg("ok");
            ajaxJson.setFlag(true);
        }catch (Exception e){
            ajaxJson.setMsg(e.getMessage());
            ajaxJson.setFlag(false);
        }
        return ajaxJson;
    }
}
